package circulate_algorithm_study;

import java.util.Scanner;

public class Num_Sum {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), x = sc.nextInt(), count = 0;
        for (int i = 1; i < n + 1; i++) {
            if (String.valueOf(i).length() == 1 & i == x) {
                count++;
            } else {
                for (int j = 0; j < String.valueOf(i).length(); j++) {
                    if (String.valueOf(i).charAt(j) == String.valueOf(x).charAt(0)){
                        count++;
                    }
                }
            }


        }
        System.out.println(count);
    }
}
